package com.lgqz.topsports.fragment;


import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lgqz.topsports.R;
import com.lgqz.topsports.adapter.CommentFragmentPagerAdapter;
import com.lgqz.topsports.databinding.FragmentNewsBinding;

import java.util.ArrayList;

/**
 * A simple {@link Fragment} subclass.
 */
public class NewsFragment extends Fragment {


    private FragmentNewsBinding binding;
    private ArrayList<String> title;

    public NewsFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        title = new ArrayList<>();
        title.add("推荐");
        title.add("国际足球");
        title.add("NBA");
        title.add("网球");
        title.add("羽毛球");
        title.add("高尔夫");
        title.add("中国足球");
        title.add("中国篮球");
        title.add("图说");
        title.add("视频");
        title.add("竞猜");
        title.add("电竞");
        title.add("最董球");
        title.add("铿锵玫瑰");
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.fragment_news,
                container, false);
        return binding.getRoot();
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        CommentFragmentPagerAdapter adapter = new CommentFragmentPagerAdapter(getFragmentManager
                (), title);
        binding.vpContainerNew.setAdapter(adapter);
        binding.tlClassificationNew.setupWithViewPager(binding.vpContainerNew);
    }
}
